"""
字符串
"""
# str1 = "aaa"
# str2 = "123"
# print("你好！！！")
# print("你好！！！",str1,str2)

# 字符串格式化
# a = 15
# b = 12345678.1234467
# s = "I love python"
# print('a = %05d' % a)
# print('b = %8.3f' % b)
# print('%17s' % s)
# print('%-17.6s' % s)

# format()
# name = "黄峰峰"
# age = 23
# sex = '女'
# temp = "我叫{2}，我今年{0}岁，我的性别是{1}"  # 大括号内可以填序号，对应参数序号（参数出现的顺序，从零开始）
# temp_01 = "我叫{}，我今年{}岁，我的性别是{}"
# print(temp.format(name,age,sex))
# print(temp_01.format(name,age,sex))

# find()
# str3 = "我在上课，有人睡觉，有人聊天，我很不开心！！！"
# str4 = "睡觉"
# print(str3.find(str4))  # 返回第一次出现的位置
# print(str3.find("111"))  # -1表示不存在、没查到
# num = str3.find(str4)
# if num == -1:
#     print("该字符串不存在！！")
# else:
#     print(str3,"'{}'在{}位置".format(str4,num))

# split()
# 默认分隔符（空格）
# str5 = "hello world !!!"
# print(str5.split())
# 指定分隔符
# str6 = "apple,banana,cherry"
# fruits = str6.split(",")
# fruits_01 = str6.split("-")
# print(fruits)
# print(fruits_01)
# 指定最大分割次数（num）
# str6 = "apple,banana,cherry"
# fruits = str6.split(",",1)
# print(fruits)

# join():连接
# res = "-".join(str5)
# print(res)
# print("-".join(str5))

# replace():替换
# str_1 = "abc def abc ghi"
# str_2 = str_1.replace("abc","123",1)
# print(str_2)

# strip():移除首尾指定字符
# str_3 = "   aaa123bbbaaa   "
# print(str_3)
# print(str_3.strip())
# print(str_3.strip(" a") + "...111")
# str_4 = "aaa123bbbaaa"
# print(str_4)
# print(str_4.strip("a"))

# 转换大小写
# str_5 = "wgferqhgeq____AFDSEEQAGA"
# print(str_5.upper())
# print(str_5.lower())

# 检测字符串是否由字母和数字组成
# print(str_5.isalnum())
# str_6 = "wgferqhgeq1564AFDSEEQAGA"
# print(str_6.isalnum())